# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=haskell-iconv
pkgver=0.4.1.3
pkgrel=1
pkgdesc='Provides an interface to the POSIX iconv library functions for string encoding conversion.'
arch=('x86_64' 'aarch64')
url='http://hackage.haskell.org/package/iconv'
license=('GPL')
makedepends=('ghc')
depends=('haskell-regex-compat' 'haskell-mtl')
install='haskell-iconv.install'
source=("http://hackage.haskell.org/packages/archive/iconv/$pkgver/iconv-$pkgver.tar.gz")
sha512sums=('b5541bbf477572f7546fa804a33243f5d126c6eb57d0fc12abd85fb9fb19dbb10a79cca60054c585845c3b755d2d5d021413d9aca4db63f5b0eaa52bba87d588')
options=('staticlibs')

build() {
  cd "iconv-$pkgver"

  runhaskell Setup configure -O -p --enable-split-objs --enable-shared \
    --prefix=/usr --docdir="/usr/share/doc/haskell-iconv" \
    --libsubdir=\$compiler/site-local/\$pkgid
  runhaskell Setup build
  runhaskell Setup haddock
  runhaskell Setup register   --gen-script
  runhaskell Setup unregister --gen-script

  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
  cd "iconv-$pkgver"

  install -dm 755 "$pkgdir/usr/share/doc/ghc/html/libraries"

  install -Dm 744 register.sh "$pkgdir/usr/share/haskell/$pkgname/register.sh"
  install -m 744 unregister.sh \
    "$pkgdir/usr/share/haskell/$pkgname/unregister.sh"
  ln -s "/usr/share/doc/$pkgname/html" \
    "$pkgdir/usr/share/doc/ghc/html/libraries/iconv"

  runhaskell Setup copy --destdir="$pkgdir"
}

